package com.zkthink.ceres.order.controller;

import com.zkthink.ceres.common.annotations.IgnoreTenant;
import com.zkthink.ceres.order.dto.comment.*;
import com.zkthink.ceres.order.entity.Comment;
import com.zkthink.ceres.order.entity.CommentKeyword;
import com.zkthink.ceres.order.entity.SensitiveKeyword;
import com.zkthink.ceres.order.service.CommentKeywordService;
import com.zkthink.ceres.order.service.CommentService;
import com.zkthink.base.controller.SuperController;
import com.zkthink.base.R;
import com.zkthink.ceres.order.service.SensitiveKeywordService;
import com.zkthink.ceres.product.dto.IdQueryDTO;
import com.zkthink.database.mybatis.conditions.Wraps;
import com.zkthink.exception.code.ExceptionCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.zkthink.security.annotation.PreAuth;

import java.util.List;
import java.util.stream.Collectors;


/**
 * <p>
 * 前端控制器
 * 评价表
 * </p>
 *
 * @author JustArgo
 * @date 2020-07-12
 */
@Slf4j
@Validated
@AllArgsConstructor
@RestController
@RequestMapping("/comment")
@Api(value = "Comment", tags = "评价表")
@PreAuth(replace = "comment:")
@IgnoreTenant
public class CommentController {

    private SensitiveKeywordService sensitiveKeywordService;

    private CommentKeywordService commentKeywordService;

    private CommentService baseService;

    @ApiOperation("新增敏感词")
    @PostMapping("addSensitiveKeyword")
    public R<Boolean> addSensitiveKeyword(@RequestBody AddSensitiveKeywordDTO addDTO){
        return sensitiveKeywordService.addSensitiveKeyword(addDTO);
    }

    @ApiOperation("删除敏感词")
    @PostMapping("/deleteSensitiveKeyword")
    public R<Boolean> deleteSensitiveKeyword(@RequestBody IdQueryDTO idQueryDTO){
        return sensitiveKeywordService.deleteSensitiveKeyword(idQueryDTO);
    }

    @ApiOperation("修改敏感词")
    @PostMapping("/updateSensitiveKeyword")
    public R<Boolean> updateSensitiveKeyword(@RequestBody SensitiveKeyword sensitiveKeyword){
        return sensitiveKeywordService.updateSensitiveKeyword(sensitiveKeyword);
    }

    @ApiOperation("分页查询敏感词列表")
    @PostMapping("findSensitiveKeywordList")
    public R<SensitiveKeywordPageDTO> findSensitiveKeywordList(@RequestBody FindKeywordListDTO keywordListDTO){
        return sensitiveKeywordService.findSensitiveKeywordList(keywordListDTO);
    }

    @ApiOperation("统一修改敏感词配置")
    @PostMapping("updateSensitiveKeywordSetting")
    public R<Boolean> updateSensitiveKeywordSetting(@RequestBody UpdateKeywordSettingDTO updateKeywordSettingDTO){
        return sensitiveKeywordService.updateSensitiveKeywordSetting(updateKeywordSettingDTO);
    }

    @ApiOperation("初始化敏感词配置")
    @PostMapping("/initSensitiveKeyword")
    public R<Integer> initSensitiveKeyword(){
        return R.success(sensitiveKeywordService.initSensitiveKeyword());
    }

    @ApiOperation("查询评论列表")
    @PostMapping("/findCommentList")
    public R<QueryCommentPageDTO> findCommentList(@RequestBody AdminQueryCommentDTO dto){
        return baseService.findCommentList(dto);
    }

    @ApiOperation("操作某一条评论")
    @PostMapping("/handleComment")
    public R<Boolean> handleComment(@RequestBody HandleCommentDTO handleCommentDTO){
        return baseService.handleComment(handleCommentDTO);
    }

    @ApiOperation("新增评价关键词")
    @PostMapping("addCommentKeyword")
    public R<Boolean> addCommentKeyword(@RequestBody AddCommentKeywordDTO addDTO){
        return commentKeywordService.addCommentKeyword(addDTO);
    }

    @ApiOperation("删除关键词")
    @PostMapping("/deleteCommentKeyword")
    public R<Boolean> deleteCommentKeyword(@RequestBody IdQueryDTO idQueryDTO){
        return commentKeywordService.deleteCommentKeyword(idQueryDTO);
    }

    @ApiOperation("修改关键词")
    @PostMapping("/updateCommentKeyword")
    public R<Boolean> updateCommentKeyword(@RequestBody CommentKeyword commentKeyword){
        return commentKeywordService.updateCommentKeyword(commentKeyword);
    }

    @ApiOperation("分页查询评价关键词列表")
    @PostMapping("findCommentKeywordList")
    public R<CommentKeywordPageDTO> findCommentKeywordList(@RequestBody FindKeywordListDTO keywordListDTO){
        return commentKeywordService.findCommentKeywordList(keywordListDTO);
    }

    @ApiOperation("统一修改关键词配置")
    @PostMapping("updateCommentKeywordSetting")
    public R<Boolean> updateCommentKeywordSetting(@RequestBody UpdateKeywordSettingDTO updateKeywordSettingDTO){
        return commentKeywordService.updateCommentKeywordSetting(updateKeywordSettingDTO);
    }

    @ApiOperation("初始化关键词配置")
    @PostMapping("/initCommentKeyword")
    public R<Integer> initCommentKeyword(){
        return R.success(commentKeywordService.initCommentKeyword());
    }
}
